<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script src="js/jquery-3.5.1.js"></script>
    <style>
        #body{
            margin: auto;
            height: 300px;
            width: 400px;
        }
    </style>
    <script>
        $(function (){
            $("#sub").click(function (){
                var $name = $("#nameId").val();
                var $pwd = $("#pwdId").val();
                $.post("loginServlet",{"name":$name,"pwd":$pwd},function (data){
                    //{"loginUser":true}
                    var loginUser = data.loginUser;
                    var $message = $("#message");
                    if (loginUser){
                        //登录成功
                        location.href = "shop_index.html";
                    }else {
                        $message.html("名字或者密码错误");
                    }
                },"json");
            });
        });
    </script>
</head>
<body>
<div id="body">
        名字<input type="text" id="nameId" >
        <br>
        pad<input type="password" id="pwdId">
        <br>
        <span id="message"></span>
        <br>
        <input type="button" value="登录" id="sub">
</div>
</body>
</html>